var path = require('path');
var utils = require('loader-utils');

module.exports = function(content){
    this.cacheable && this.cacheable();
    var options = utils.parseQuery(this.query);

    var loaderCode = [
        '// loader svg into dom',
        'var content = ' + utils.stringifyRequest(this, content),
        '// require the function to add svg into dom',
        'var __importSVG = require(' + utils.stringifyRequest(this, '!' + path.join(__dirname, 'libs/svg.js')) + ');',
        '// add svg content into dom',
        '__importSVG(content, ' + JSON.stringify(options) + ');',
        ''
    ].join('\n');

    return loaderCode;
}